/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function launcherCash(){
    jQuery(document).ready(function(){
        
        //femmesNew();
        //enfantsNew();
        //bebesNew();
    });
    
}


function femmesNew(){
    
    jQuery.ajax({
        type:'post',
        url:'index.php?option=com_cashestimation&view=estimations&format=json&task=new_product&virtuemart_category_id=8',
        dataType:'JSON',
        success:function(data){
            displayProd("#display_new_femmes", data.data);
            //jQuery("#display_new_femmes").html('<img src="/cashdressing.com/'+data.data[0]['image']+'" />')
        }
    });
}
 function step2(f, url){//passer de l'étape 1 à la 2 lors de la demande de sac!
            
            if (document.formvalidator.isValid(f)) {
       
                    window.location.href=url;
                    return true;
		} else {
			
			alert('Votre adresse n\'est pas valide');
                        return false;
		}
        }
        
 function step22(url){//valide la demand de sac
     
     var bValid= true;
     
     if(jQuery("input[name=croix_rouge]:checked").val()!=='oui' && jQuery("input[name=croix_rouge]:checked").val()!=='non')
         bValid= false;
     
     if(jQuery("input[name=conditions_ventes]:checked").val()!=='lue' )
        bValid= false;
     if(jQuery("input[name=conditions_envoie]:checked").val()!=='vet')
        bValid= false;
     if(jQuery("input[name=conditions_marques]:checked").val()!=='marq')
         bValid= false;
     if(bValid===true){
         window.location.href=url;
     }else{
         alert("Vous devez cocher toutes les cases");
     }
     
 }
function enfantsNew(){
    
    jQuery.ajax({
        type:'post',
        url:'index.php?option=com_cashestimation&view=estimations&format=json&task=new_product&virtuemart_category_id=7',
        dataType:'JSON',
        success:function(data){
            displayProd("#display_new_enfant", data);
        }
    });
}

function bebesNew(){
    
    jQuery.ajax({
        type:'post',
        url:'index.php?option=com_cashestimation&view=estimations&format=json&task=new_product&virtuemart_category_id=9',
        dataType:'JSON',
        success:function(data){
            displayProd("#display_new_bebe", data);
        }
    });
}

function displayProd(id, data){
    var html=[];
    var i=1;
    html.push('<table><tr>');//<ul class="thumbnails">
    jQuery.each(data, function(idx,ele){
            html.push('<td><img id="'+idx+'" src="/cashdressing.com/'+ele['image']+'"/></td>');
    });
    
    html.push('</tr></table>');
     jQuery(id).html(html.join(''));
     
      jQuery(id).find('img').css("width", "25%");
      jQuery(id).css("height", "10%");
    
}